package test.app.factory;

import java.util.ResourceBundle;

import test.app.HibernateImpl.ContenidoHibernateImpl;
import test.app.impl.ContenidoImpl;
import test.app.impl.FacadeImpl;
import test.app.impl.ImplementacionImpl;
import test.app.interfaces.Contenido;
import test.app.interfaces.Facade;
import test.app.interfaces.Implementacion;

public class Factory 
{
	private static ResourceBundle resourceBundle;
	
	static
	{
		resourceBundle = ResourceBundle.getBundle("app");
	}
/*
	public static Facade getFacade()
	{
		return new FacadeImpl();
	}

	public static Implementacion getImplementacion()
	{
		return new ImplementacionImpl();
	}

	public static Contenido getContenido() {
		//Utilizando JDBC: return new ContenidoImpl();
		
		//Utilizando Hibernate
		return new ContenidoHibernateImpl();
	}
*/	
	public static Object getInstance(String nombre)
	{
		try 
		{
			String className = resourceBundle.getString(nombre);
			
			return Class.forName(className).newInstance();
			
		} catch (Exception ex) 
		{
			ex.printStackTrace();
			throw new RuntimeException(ex);
		}
	}
}
